home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 44 / Amiga Format CD44 (1999-08-26)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-10].iso / -in_the_mag- / basics / amos / moreuselssprgs.lha / AnimPlayer.AMOS / AnimPlayer.amosSourceCode
AMOS Source Code  |  1997-04-15  |  3KB  |  92 lines

  1. ' ************************************ 
  2. ' *                                  * 
  3. '�*      AMOS Anim Player V1.0       * 
  4. ' *     Written by Chris Hodges      * 
  5. ' *                                  * 
  6. ' ************************************ 
  7. '
  8. ' This animation player was written to load anims that are larger than the 
  9. ' available memory. Due to the instant loading, it isn't useful to load
  10. ' anims from disk and because disk anims can't be larger than aproximately 
  11. ' 840 KB, the memory should be sufficent to load it using Iff Anim.
  12. ' NOTE: There must be a bug either in this program or in AMOS Pro because in 
  13. '       one of my 4MB anims the display got very, very corrupted (plus memory  
  14. '       corruption). After analysing the length of the frames, I found out 
  15. '       that frames that exceed the 40000 Bytes threshold make the display 
  16. '       corrupt. Please write to my, if you have the same problem or want  
  17. '       to have some neat fractal landscape anims. 
  18. '
  19. '       Christopher Hodges 
  20. '       Kennedystr. 8
  21. '       82178 Puchheim 
  22. '       W-Germany
  23. '       Tel. 089/805847
  24. '
  25. ' Key functions: 
  26. ' F1-F10: Set replay speed. F1=Screen update every 50th of a second
  27. '                           F10=Update every 5th of a second 
  28. ' Space : Pause animation
  29. ' "a"   : Advance one frame  
  30. ' ESCape: Exit 
  31. '
  32. Screen Open 0,640,80,2,$8000
  33. Dim F(500),L(500)
  34. F$=Fsel$("*.anim","","Select an IFF-Anim","")
  35. If F$="" Then End 
  36. Hide 
  37. Open In 1,F$
  38. LE=Lof(1) : MXFR=0 : DLTA=0
  39. A$=Input$(1,12)
  40. If Left$(A$,4)<>"FORM" or Right$(A$,4)<>"ANIM" Then Print "Not an IFF-ANIM file!" : End 
  41. Print "Length of animation:";LE;" Bytes."
  42. Print "Counting frames..."
  43. P=12
  44. Repeat 
  45.   Pof(1)=P : F(MXFR)=P
  46.   A$=Input$(1,8)
  47.   L(MXFR)=Leek(Varptr(A$)+4)+8
  48.   If DLTA=0 Then DLTA=L(MXFR) Else DLTA=(DLTA+L(MXFR))/2
  49.   Add P,L(MXFR) : Inc MXFR
  50. Until P=LE
  51. Print "Number of frames:";MXFR-2
  52. Print "Average DLTA length:";DLTA;" Bytes per frame."
  53. Print : Print "Press a key to start."
  54. Wait Key 
  55. Dec MXFR
  56. FIRST=0 : FR=0 : DB=0 : WA=1 : RPSP=1 : PAUS=0 : Timer=0 : FAD=32
  57. Repeat 
  58.   I$=Upper$(Inkey$) : SC=Scancode : Clear Key 
  59.   If I$=" " Then PAUS=1-PAUS
  60.   If SC>79 and SC<90 Then RPSP=SC-79
  61.   If FAD<32 Then Add FAD,-Timer-1
  62.   If(PAUS=0) or(I$="A")
  63.     Gosub ANI
  64.   Else 
  65.     Timer=0 : Wait Vbl 
  66.   End If 
  67.   If Mouse Key>0 or I$=Chr$(27) Then Dec FAD : Fade 3
  68. Until FAD<=0
  69. Close 1
  70. Screen Close 0
  71. End 
  72. ANI:
  73.   DB=1-DB
  74.   Reserve As Work 9+DB,L(FR)+12
  75.   ST=Start(9+DB)
  76.   Pof(1)=F(FR) : Sload 1 To ST,L(FR)+12
  77.   If FR=MXFR Then Poke$ ST+L(FR),"FORM"+String$(Chr$(0),4)+"ILBM"
  78.   While Timer<Max(WA,RPSP) : Wait Vbl : Wend 
  79.   Timer=0
  80.   If FIRST=0
  81.     X=Frame Play(ST,1,0)
  82.     Paper 0 : Pen 1
  83.     Double Buffer 
  84.     Autoback 0
  85.     FIRST=1
  86.   Else 
  87.     X=Frame Play(ST,1)
  88.   End If 
  89.   Screen Swap 
  90.   Inc FR : If FR>MXFR Then FR=2
  91.   WA=Max(Frame Param,1)
  92. Return